//
//  StatusCellBottomView.swift
//  weibo
//
//  Created by 吴婷婷 on 15/11/10.
//  Copyright © 2015年 wutingting. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {
    ///MARK: - 构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //MARK: - 懒加载控件
    //转发按钮
    private lazy var retweetButton: UIButton = UIButton (title: " 转发",
        fontSize: 12,
        ImageName: "timeline_icon_retweet",
        color: UIColor.lightGrayColor())
    //评论按钮
    private lazy var remarkButton: UIButton = UIButton (title: " 评论",
        fontSize: 12,
        ImageName: "timeline_icon_comment",
        color: UIColor.lightGrayColor())
    //点赞按钮
    private lazy var  likeButton: UIButton = UIButton (title: " 赞",
        fontSize: 12,
        ImageName: "timeline_icon_unlike",
        color: UIColor.lightGrayColor())
}
//MARK: - 设置界面
extension StatusCellBottomView {
    func setupUI() {
        
        backgroundColor = UIColor(white: 0.8, alpha: 1)
        
        addSubview(retweetButton)
        addSubview(remarkButton)
        addSubview(likeButton)
        
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        remarkButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetButton.snp_top)
            make.left.equalTo(retweetButton.snp_right)
            make.height.equalTo(retweetButton.snp_height)
            make.width.equalTo(retweetButton.snp_width)
        }
        
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(remarkButton.snp_top)
            make.left.equalTo(remarkButton.snp_right)
            make.height.equalTo(remarkButton.snp_height)
            make.width.equalTo(remarkButton.snp_width)
            make.right.equalTo(self.snp_right)
        }
        
        //3.设置分割线
        let sepLeft = sepLine()
        let sepRight = sepLine()
        addSubview(sepLeft)
        addSubview(sepRight)
        
        let sepWidth = 0.5
        let sepScale = 0.4
        //约束
        sepLeft.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(sepWidth)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(sepScale)

        }
        sepRight.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(likeButton.snp_centerY)
            make.right.equalTo(likeButton.snp_left)
            make.width.equalTo(sepWidth)
            make.height.equalTo(likeButton.snp_height).multipliedBy(sepScale)
            
        }
    }
    
   
    
    private func sepLine() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
}
